找到与字典中的项目对应的键(Finding the key corresponding to an item in a dictionary) 您所在的位置:网站首页 vba dictionary用法 找到与字典中的项目对应的键(Finding the key corresponding to an item in a dictionary)

找到与字典中的项目对应的键(Finding the key corresponding to an item in a dictionary)

2023-03-28 10:38| 来源: 网络整理| 查看: 265

有什么方法可以找到与VBA词典中给定项目相对应的键?

http://msdn.microsoft.com/en-us/library/aa164502%28v=office.10%29.aspx MSDN建议可以使用“Key”属性,但是当我尝试使用它时,出现错误( “编译错误:财产的无效使用”)。 我在过去发现,这里给出的“Exists”方法对我来说也不起作用,所以我认为它们是以前版本Office中的命令,现在已经过时。 但是,我一直无法找到最新版本的Office的等价物。

我可以使用for循环来创建一个新的字典,其中旧字典中的键是新字典中的项(反之亦然),然后使用“.Item”,但我想知道是否有内置命令会让我避免这一点。

Is there any way to find the key that corresponds to a given item in a VBA dictionary?

http://msdn.microsoft.com/en-us/library/aa164502%28v=office.10%29.aspx MSDN suggests that the "Key" property can be used, but when I try using it I get an error ("Compile error: invalid use of property"). I've found in the past that the "Exists" method given here doesn't work for me either, so I assume that they were the commands in a previous version of Office and are now outdated. However I haven't been able to find an equivalent for the latest version of Office.

I could use a for each loop to create a new dictionary where the keys in the old dictionary are the items in the new dictionary (and vice versa) and then use ".Item", but I was wondering if there was an inbuilt command that would allow me to avoid this.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有